#include "fxcc/yml/Serializer.h"
#include "fxcc/core/graph/common/MaterialData.h"

using namespace fxcc::yml;
using namespace fxcc::graph::common;

template<>
void Serializer::Encode<MaterialData::Paths>(YAML::Node& node, const MaterialData::Paths& inst)
{
    SetArrayVariable<std::string>(node, "m_Textures", inst.m_Textures);
}


template<>
bool Serializer::Decode<MaterialData::Paths>(const YAML::Node& node, MaterialData::Paths& inst)
{
    GetArrayVariable<std::string>(node, "m_Textures", inst.m_Textures);
    return true;
}

template<>
void Serializer::Encode<MaterialData>(YAML::Node& node, const MaterialData& inst)
{
    Encode<fxcc::Base>(node, inst);
    SetVariable<std::string>(node ,"m_Name",inst.m_Name);
    SetVariable<std::string>(node, "m_Dir", inst.m_Dir);
    SetVariable<fxcc::graph::common::Params>(node, "m_Params", inst.m_Params);
    SetMapVariable<std::string>(node, "m_Strings", inst.m_Strings);
    SetMapVariable<MaterialData::Paths>(node, "m_Textures", inst.m_Textures);

}


template<>
bool Serializer::Decode<MaterialData>(const YAML::Node& node, MaterialData& inst)
{
    Decode<fxcc::Base>(node, inst);
    GetVariable<std::string>(node, "m_Name", inst.m_Name);
    GetVariable<std::string>(node, "m_Dir", inst.m_Dir);
    GetVariable<fxcc::graph::common::Params>(node, "m_Params", inst.m_Params);
    GetMapVariable<std::string>(node, "m_Strings", inst.m_Strings);
    GetMapVariable<MaterialData::Paths>(node, "m_Textures", inst.m_Textures);

	return true;
}